import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class DigitalTriangle {
    private static int max;
    private static int n;

    private static class Node {
        int val;
        Node left;
        Node right;
        Node(int val) {
            this.val = val;
        }
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int col = scan.nextInt();
        n = col;
        int val = scan.nextInt();
        Node root = new Node(val);
        Deque<Node> deque = new LinkedList<>();
        deque.offer(root);
        for (int i = 2; i <= col; i++) {
            List<Node> list = new LinkedList<>();
            for (int j = 0; j < i; j++) {
                list.add(new Node(scan.nextInt()));
            }
            int size = deque.size();
            int index = 0;
            for (int j = 0; j < size; j++) {
                Node node = deque.poll();
                node.left = list.get(index);
                if (j == 0) {
                    deque.offer(node.left);
                }
                node.right = list.get(++ index);
                deque.offer(node.right);
            }
        }
        findMax(root, 0, 0, 0);
        System.out.println(max);
        scan.close();
    }

    public static void findMax(Node root, int sum, int left, int right) {
        if (left > n / 2 + 1 || right > n / 2 + 1) {
            return;
        }
        if (root == null) {
            max = Math.max(max, sum);
            return;
        }
        sum += root.val;
        findMax(root.left, sum, root.left == null ? left :left + 1, right);
        findMax(root.right, sum, left, root.right == null ? right : right + 1);
    }
}
